# mypackage/__init__.py
import logging
import sys

# 创建包级 Logger 对象
_logger = logging.getLogger(__name__)
_logger.setLevel(logging.DEBUG)  # 默认日志级别

# 设置控制台 Handler
_console_handler = logging.StreamHandler(sys.stdout)
_console_handler.setLevel(logging.DEBUG)

# 设置日志格式
_formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S'
)
_console_handler.setFormatter(_formatter)

# 添加 Handler
_logger.addHandler(_console_handler)

# 对外暴露 Logger 对象
logger = _logger
